<template>
	<el-dialog title="" width="60%" visible :show-close="false" :append-to-body="true" class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		<div class="bt">{{vtitle}}</div>
		<div style="width: 98%; text-align: right;margin-top: 20px;">
			<el-button type="success" class="submit" @click="add">继续保存</el-button>
			<el-button type="warning" class="submit" @click="cancel">返回</el-button>
		</div>
		<div style="margin-top: 20px;">
			<ul class="kblistul">
				<li v-for="i in this.kblistul" @click="daike(i)" :class="(i.issk=='Y'? 'red':'red2')" :style="i.iscf > 0 || i.lsiscf > 0? 'background:red;color:#fff':''">
					<p>{{i.sj}}</p>
					<p>{{i.week}}</p>
					<p>{{i.jsmc}}</p>
					<p>{{i.dklsmc ? i.dklsmc : i.zwm}}</p>
					<p>{{i.sjd}}</p>
				</li>
			</ul>
		</div>
		<!--<div style="color: red;text-align: center; font-size: 20px;" v-if='ct'>
				课表没有冲突！
			</div>-->

	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				ct: false,
				vtitle: '检查冲突',
				kblistul: [],
			}
		},

		created() {
			console.log(this.params, 8989565)
			this.bjid = this.params.list.id
			this.day = this.params.id
			this.getkblist()
		},

		methods: {
			getkblist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					isys: 'Y',
					xxid: logininfo.xxid,
					yhid: logininfo.id,
					bjid: this.bjid
				})
				//执行
				this.axios.post(this.$store.state.api + 'ysbj/getbjkb', params2)
					.then(res => {
						this.kblistul = res.data.data.aa
						if(this.kblistul == '') {
							this.ct = true;
						}
//						console.log(res, 9999)
					}).catch(res => {
						this.$message.warning("服务器异常");
						this.$store.state.loading = false;
					})
			},
			add() {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					day: this.day,
					bjid: this.bjid
				})
				//执行
				this.axios.post(this.$store.state.api + 'bj/insertcl1', params2)
					.then(res => {
						console.log(res, 9999)
						if(res.data.code == "1"){
							this.$emit('close', {
								type: 'edit',
								cancel: true
							})	
							this.$message.success("保存成功!");
						}
					}).catch(res => {
						console.log(res, 9999222)
						this.$message.warning("服务器异常");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', {
					type: 'edit',
					cancel: false
				})
			},

		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.topdiv {
			float: left;
			margin-left: 20px;
			height: 50px;
			line-height: 50px;
			;
		}
		.close {
			z-index: 10;
			position: absolute;
		}
		.red {
			background: #C0CCDA;
		}
		.red2 {
			background: #fff;
		}
		.kblistul {
			width: 97%;
			text-align: center;
			margin: 0 auto;
			border: 1px solid;
			overflow: hidden;
			li {
				width: 12.5%;
				border: 1px solid;
				float: left;
			}
		}
		.bt {
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color: white;
			text-align: left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.tab {
			width: 93%;
			margin: 0 auto;
			border: 1px solid #D8DCE5;
			margin-top: 10px;
			tr {
				border: 1px solid #D8DCE5;
			}
			td {
				text-align: center;
				border: 1px solid #D8DCE5;
				div {
					height: 50%;
					line-height: 50px;
					/*border: 1px solid #D8DCE5;*/
					overflow: hidden;
					span {
						width: 13%;
						height: 50px;
						border: 1px solid #D8DCE5;
						/*$width: width:calc(100% - 50px);*/
						/*width: $width/2;*/
						float: left;
					}
				}
			}
		}
	}
</style>